import React, { Component } from 'react'
import {
  View,
  StyleSheet,
  Image,
  Text,
  TouchableOpacity
} from 'react-native'

import NavBar from '../../../../components/PublicHeader/index';

export default class authentication extends Component {
  constructor(props) {
    super(props)
    const {
      currentAccount,
      defaultTrue,
      goBackTrue,
      typeTrue,
      typeUser,
      key
    } = this.props.navigation.state.params
    this.state = {
      // 头部标题
      topTitle: "企业账户",
      currentAccount: currentAccount,
      defaultTrue: defaultTrue,
      goBackTrue: goBackTrue,
      key: key,
      enterKey: key,
      typeTrue: typeTrue,
      typeUser: typeUser,

      // 资源数据
      authentication: require("../../../../assets/images/iconResources/authentication.png"),
    };
  }

  componentDidMount = () => {
  }
  enterAccountA() {
    const {
      currentAccount,
      key,
      goBackTrue,
      typeUser,
      typeTrue,
      enterKey
    } = this.state
    this.props.navigation.navigate("businLicense",
      {
        currentAccount: currentAccount,
        goBackTrue: goBackTrue,
        key: key,
        enterKey: enterKey,
        typeUser: typeUser,
        typeTrue: typeTrue
      })
  }
  updateAccountU() {
    const {
      key,
    } = this.state
    this.props.navigation.goBack(key);
  }


  render() {
    const {
      key,
      defaultTrue,
      goBackTrue,
      topTitle,
      enterKey,
      authentication
    } = this.state
    return (
      <View style={styles.warper}>
        {/* 导航栏 */}
        <NavBar
          navigation={this.props.navigation}
          title={topTitle}
          titleColor={"#333"}
          goBackTrue={goBackTrue}
          keyGoBack={key}
          enterKey={enterKey}
        />
        <View style={styles.authenticationWAR}>
          <View style={styles.authenticationImg}>
            <Image style={styles.imgAuthentication}
              source={authentication} />
            <Text style={styles.text}>{
              defaultTrue ?
                "恭喜你认证成功！" : "恭喜你修改成功！"}</Text>
          </View>
        </View>
        <TouchableOpacity
          style={styles.authenticationBox}
          onPress={() => {
            !goBackTrue ?
              this.enterAccountA() : this.updateAccountU()
          }}>
          <View style={styles.authenticationBtn}>
            <Text
              style={styles.authenticationText}>
              立即查看
            </Text>
          </View>
        </TouchableOpacity>
      </View>
    )
  }
}
const styles = StyleSheet.create({
  warper: {
    backgroundColor: "#fff",
    flex: 1,
  },
  authenticationWAR: {
    paddingTop: 15,
    paddingLeft: 15,
    paddingRight: 15
  },
  text: {
    marginBottom: 30,
    color: "#333",
    fontSize: 18
  },
  authenticationText: {
    textAlign: "center",
    color: "#fff",
    fontSize: 18
  },
  authenticationBox: {
    width: "100%",
    height: 40,
    marginTop: 20,
    paddingLeft: 15,
    paddingRight: 15,
    justifyContent: "center",
    alignItems: "center",
  },
  authenticationBtn: {
    width: "60%",
    height: 40,
    justifyContent: "center",
    alignItems: "center",
    borderRadius: 50,
    backgroundColor: "#1890FF"
  },
  authenticationImg: {
    justifyContent: "center",
    alignItems: "center"
  },
  imgAuthentication: {
    width: "50%",
    height: "50%",
    marginBottom: 20,
    borderRadius: 6
  },
})